/*
 * @Descripttion: 
 * @version: 
 * @Author: cyj
 * @Date: 2022-12-30 12:07:37
 */
//存储用户信息
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
    state: () => {
        return {
            //是否登录 默认是false
            isLogin: false,
            //用户的私人歌单
            userSongList: [],
            //登录用户信息
            userInfo: null,
            //用户喜欢的音乐id列表
            likeSongIds: [],
        }
    },
    getters: {

    },
    actions: {
        //保存用户喜欢的音乐id列表
        saveLikeSongIds(ids) {
            this.likeSongIds = ids
        },
        //更新登录状态
        updateLogin(status) {
            this.isLogin = status
        },
        //清空用户信息
        clearUserInfo() {
            this.userInfo = null
        },
        //清空用户私人歌单
        clearUserSongList() {
            this.userSongList = []
        },
        //清空用户喜欢音乐id列表
        clearUserLikeSongIds() {
            this.likeSongIds = []
        }

    },
    persist: {
        enabled: true,
        strategies: [
            { storage: localStorage }
        ]
    }

})